import { SupplierInfoAction } from '../actions'
import { SupplierInfoType } from '../Types'
import { 
  RecordSupplierInfo_PENDING, 
  RecordSupplierInfo_FULFILLED} from '../Constants'
// 初始化
const initState= {
  loading: false,
  record: {}
}
export function SupplierInfoReducer(state: SupplierInfoType = initState, action: SupplierInfoAction): SupplierInfoType {
  switch (action.type) {
    case RecordSupplierInfo_PENDING:
      return { ...state, loading: true }
    case RecordSupplierInfo_FULFILLED:
      return {
        ...state,
        loading: false,
        record: action.payload[0]
      }
  }
  return state
}